import java.util.Iterator;


public class RoundRobin<T> implements HeaderList<T>{
	
	private class Node{
		private T head;
		private Node tail;
		
		private Node(T head, Node tail){
			this.head=head;
			this.tail=tail;
		}		
		
		private boolean hasNext(){
			return !((Object)tail).equals(first);
		}
	}
	
	private class MyIterator implements Iterator<T>{
		private Node previous;
		private Node current;
		
		private MyIterator(){
			previous=first;
			current=first;
		}
		
		public boolean hasNext() {
			return current.hasNext();
		}

		public T next() {
			current=current.tail;
			return current.head;
		}

		public void remove() {
			
			
		}
		
	}
	
	private int size=0;
	private Node first;
	private Node last;
	
	public RoundRobin(){
	}

	public RoundRobin(T elem){
		add(elem);
	}
	
	public void add(T elem) {
		if(size==0){
			first=new Node(elem,first);
			last=first;
		}else{
			last.tail=new Node(elem,first);
		}
		size++;
	}

	private Node get(T elem){
		int current=size;
		Node n=first;
		
		while(!(current==0) && n.hasNext()){
			if(n.head.equals(elem)){
				return n;
			}
			n=n.tail;
		}
		return null;
	}
	
	public boolean contains(T elem) {
		return get(elem)!=null;
	}

	public boolean isEmpty() {
		return size==0;
	}

	public Iterator<T> iterator() {
		return new MyIterator();
	}

	@Override
	public T next() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean remove(T elem) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void reset() {
		// TODO Auto-generated method stub
		
	}
	
	
	
	
	
}